//
//  RTJNoInvestmentController.m
//  RuiTaiJinProject
//
//  Created by jayson on 2018/12/11.
//  Copyright © 2018年 leewei. All rights reserved.
//

#import "RTJNoInvestmentController.h"
#import "RTJBidRecordsCell.h"

@interface RTJNoInvestmentController ()

@property (nonatomic, strong) NSMutableArray *data;
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation RTJNoInvestmentController

-(NSMutableArray *)data {
    if (!_data) {
        _data = [NSMutableArray array];
    }
    
    return _data;
}

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    self.tableView.tableFooterView=[UIView new];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
    self.tableView.estimatedRowHeight=300;
    
    [self loadData];
}

-(void)loadData{
    
    
    [SVProgressHUD  showWithStatus:nil];
    
    [self.view showEmptyViewWithStr:@"" image:nil callback:nil];
    
    [RTJNetWork asyncRequestWithURL:@"user/invite_list" params:nil method:GET zxCompletion:^(id data, NSInteger status, BOOL success, NSString *errorMsg) {
        
        [SVProgressHUD dismiss];
        [self.view removeEmptyView];

    
        if (success) {
            
            if ([data[@"status"]integerValue] == 1) {
                
                [self.data removeAllObjects];
                
                NSArray *arr = [NSArray array];
                arr = data[@"data"][@"unload_user"];
                [self.data addObjectsFromArray:arr];
                
                if (self.data.count == 0) {
                    
                    [self.view showEmptyViewWithStr:@"您暂无好友投资数据" image:[UIImage imageNamed:@"kbylogo"] callback:^{
                        [self loadData];
                    }];
                    
                }else{
                    
                    [self.tableView reloadData];
                }
                
                
            }else{
                
                [SVProgressHUD showErrorWithStatus:[NSString stringWithFormat:@"%@",data[@"msg"]]];
                [self.view showEmptyViewWithStr:errorMsg image:[UIImage imageNamed:@"kbylogo"] callback:^{
                    [self loadData];
                }];
                
            }
            
        }else{
            
            [SVProgressHUD showErrorWithStatus:[NSString stringWithFormat:@"%@",errorMsg]];
            [self.view showEmptyViewWithStr:errorMsg image:[UIImage imageNamed:@"kbylogo"] callback:^{
                [self loadData];
            }];

        }

        
    }];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return  self.data.count;
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return UITableViewAutomaticDimension;
    
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString * ID = @"RTJBidRecordsCell";
    
    RTJBidRecordsCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    
    if (!cell) {
        
        cell = [[NSBundle mainBundle] loadNibNamed:@"RTJBidRecordsCell" owner:self options:nil][3];
    }
    
    NSString *real_name = _data[indexPath.row][@"real_name"];
    cell.real_name1.text = real_name.length!=0 ? real_name : @"未实名";
    cell.phone1Lab.text = [NSString stringWithFormat:@"%@",_data[indexPath.row][@"mobile"]];
    cell.zhuceLab1.text = [NSString stringWithFormat:@"注册时间：%@",_data[indexPath.row][@"create_time"]];
    cell.selectionStyle=UITableViewCellSelectionStyleNone;

    return  cell;
    
}





@end
